import math

class Standard1D(object):
	def __init__(self, data, name, nodes, material, originallength=None, fields=[], loads=[], *arguments, **keywords):
		super(Standard1D, self).__init__()
		self.data = data
		self.name = name
		self.nodes = nodes
		self.material = material
		if originallength is None:
			l2 = 0.0
			for i in range(0, self.data.settings.dimensions):
				l2 += (nodes[0].position.x[i]-nodes[1].position.x[i])**2				
			self.originallength = math.sqrt(l2)
		else:
			self.originallength = originallength
		self.fields = fields
		self.loads = loads
	
	def deleteMember(self):
		del self.data.members[self.name]
	
	def __repr__(self):
		return "{Standard1D: {name: %s, nodes: %s, material: %s, fields: %s, loads: %s, originallength: %s}}" % (self.name, self.nodes, self.material, self.originallength, self.fields, self.loads)
